package numberutil

import (
	"strings"

	"github.com/gin-gonic/gin"

	"gitee.com/cs-character-cloud/character-cloud-util/util"
	webserver "gitee.com/cs-character-cloud/character-cloud-util/web_server"
)

// numberToUp 数字转大写
func (*numberUtil) numberToUp(c *gin.Context) {
	strNum := c.DefaultQuery("number", "0")
	if strings.LastIndexAny(strNum, ".") == 0 {
		strNum += ".00"
	} else if strings.LastIndexAny(strNum, ".") == len(strNum)-1 {
		strNum += "0"
	}
	msg, err := util.NumberToUp(strNum)
	if err != nil {
		webserver.Fail(c, err)
		return
	}
	webserver.Success(c, "转换成功", msg)
}
